<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>浮动元素高度自适应</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box1,.box2{
            width: 200px;
            height: 200px;
        }
        .box1{
            background: red;
            float: left;
        }
        .box2{
            background: green;
            float: left;
        }
        .box::after{
            content: "";
            clear: both;
            display: block;
        }
        .box3{
            width: 400px;
            height: 400px;
            background: blue;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="box1"></div>
        <div class="box2"></div>
    </div>
    <div class="box3"></div>
</body>
</html>